/**
 * 
 */
package de.cbf.cam.dsa.inventory.composites;

import java.util.List;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;

/**
 * @author Nebelritter
 *
 */
public class CompositeChooseInventoryPosition extends Composite {

	private Combo comboInventoryPosition;
	/**
	 * @param parent
	 * @param style
	 */
	public CompositeChooseInventoryPosition(Composite parent, int style) {
		super(parent, style);
		
		GridLayout layout = new GridLayout(1,false);
		setLayout(layout);
		
		comboInventoryPosition = new Combo(this, SWT.DROP_DOWN);
		comboInventoryPosition.setLayoutData(new GridData(GridData.FILL_BOTH));
		
	}

	public void setItems(List<String> positions){
		comboInventoryPosition.setItems(positions.toArray(new String[0]));
	}
	
	public String getChosenPosition(){
		int index = comboInventoryPosition.getSelectionIndex();
		String item = comboInventoryPosition.getItem(index);
		return item;
	}
}
